
# 先转化为10进制，计算完成后再回到30进制
# 2g50ttaq 0st9hk381
# 11feik2ir
thirddict={'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, \
    'a': 10, 'b': 11, 'c': 12, 'd': 13, 'e': 14, 'f': 15, 'g': 16, 'h': 17, 'i': 18, 'j': 19,\
    'k': 20, 'l': 21, 'm': 22, 'n': 23, 'o': 24, 'p': 25, 'q': 26, 'r': 27, 's': 28, 't': 29}

dec2=[str(i) for i in range(10)]
dec2.extend([chr(i+87) for i in range(10,30)]) 
def third2dec(nums:str):
    P=30
    res=[thirddict[i] for i in nums]
    # for i in nums:
    #     if i.isdigit():
    #         res.append(int(i))
    #     else:
    #         res.append(ord(i)-87)
    y,product=0,1
    for i in res[::-1]:
        y=y+i*product
        product=product*P
    
    return y

a,b=input().split()
ansdec=third2dec(a)+third2dec(b)

def dec2base30(num:int):
    res=[]
    while num:
        num,temp=divmod(num,30)
        res.append(dec2[temp])

    return res
    
ans=dec2base30(ansdec)[::-1]
res="".join(ans)

print(res.lstrip('0')) #去除前导0


